+1999-10-28 Jonathan Blandford <jrb@redhat.com>
+
+ * src/io-tiff.c (image_load_increment): started work on the tiff
+ non-incremental loader.
+
+ * src/io-gif.c (image_load_increment): started work on the gif
+ incremental loader.
+
+ * src/gdk-pixbuf-io.h: Changed ModuleType to GdkPixbufModule.
+
1999-10-27 Federico Mena Quintero <federico@redhat.com>
* src/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): New
}
#endif
-ModuleType file_formats [] = {
+GdkPixbufModule file_formats [] = {
{ "png", pixbuf_check_png, NULL, NULL, NULL, NULL, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL, NULL, NULL, NULL },
{ "tiff", pixbuf_check_tiff, NULL, NULL, NULL, NULL, NULL, NULL },
};
static void
-image_handler_load (ModuleType *image_module)
+image_handler_load (GdkPixbufModule *image_module)
{
char *module_name;
char *path;
\f
-ModuleType *
+GdkPixbufModule *
gdk_pixbuf_get_module (gchar *buffer, gint size)
{
gint i;
gint size;
FILE *f;
char buffer [128];
- ModuleType *image_module;
+ GdkPixbufModule *image_module;
f = fopen (filename, "r");
if (!f)
typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
-typedef struct _ModuleType ModuleType;
-struct _ModuleType {
+typedef struct _GdkPixbufModule GdkPixbufModule;
+struct _GdkPixbufModule {
char *module_name;
gboolean (* format_check) (guchar *buffer, int size);
GModule *module;
};
-ModuleType *gdk_pixbuf_get_module (gchar *buffer, gint size);
+GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, gint size);
gboolean closed;
gchar buf[128];
gint buf_offset;
- ModuleType *image_module;
+ GdkPixbufModule *image_module;
gpointer context;
} GdkPixbufLoaderPrivate;
#include <glib.h>
#include <gif_lib.h>
#include "gdk-pixbuf.h"
-
+#include "gdk-pixbuf-io.h"
\f
/* Destroy notification function for the libart pixbuf */
gint fn, is_trans = FALSE;
gint done = 0;
gint t_color = -1;
- gint w, h, i, j;
+ gint w = 0, h = 0, i, j;
guchar *pixels, *tmpptr;
GifFileType *gif;
- GifRowType *rows;
+ GifRowType *rows = NULL;
GifRecordType rec;
ColorMapObject *cmap;
int intoffset[] = { 0, 4, 2, 1 };
w, h, is_trans ? (w * 4) : (w * 3),
free_buffer, NULL);
}
+
+
+/* Progressive loader */
+typedef struct _GifData GifData;
+struct _GifData
+{
+ ModulePreparedNotifyFunc *func;
+ gpointer user_data;
+
+ GifFileType *gif_handle;
+ guchar *buf;
+ guint ptr;
+ gint size;
+};
+
+gpointer
+image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data)
+{
+ GifData *context;
+
+ context = g_new (GifData, 1);
+ context->func = func;
+ context->user_data = user_data;
+ context->buf = NULL;
+ context->gif_handle = NULL;
+ return context;
+}
+
+int
+myInputFunc (GifFileType *type, GifByteType *byte, int length)
+{
+ GifData *context;
+
+ context = (GifData *) type->UserData;
+ g_print ("in myInputFunc\nSize requested is %d\n", length);
+
+ if (length > context->size - context->ptr) {
+ memcpy (byte, context->buf + context->ptr, context->size - context->ptr);
+ return context->size - context->ptr;
+ }
+
+ memcpy (byte, context->buf + context->ptr, length);
+ return length;
+}
+
+void
+image_stop_load (gpointer context)
+{
+ g_free ((GifData *) context);
+}
+
+gboolean
+image_load_increment (gpointer data, guchar *buf, guint size)
+{
+ GifData *context = (GifData *) data;
+
+ g_print ("in load_increment: %d\n", size);
+ context->buf = g_realloc (context->buf, size);
+ context->ptr = 0;
+ context->size = size;
+ memcpy (context->buf, buf, size);
+
+ if ((context->gif_handle == NULL) && (context->size > 20))
+ context->gif_handle = DGifOpen (context, myInputFunc);
+
+ g_print ("width = %d, height = %d\n", context->gif_handle->SWidth, context->gif_handle->SHeight);
+ return FALSE;
+}
/* Following code (almost) blatantly ripped from Imlib */
#include <config.h>
-#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <tiffio.h>
#include "gdk-pixbuf.h"
+#include "gdk-pixbuf-io.h"
\f
w, h, w * 4,
free_buffer, NULL);
}
+
+/* Progressive loader */
+
+/*
+ * Tiff loading progressively cannot be done. We write it to a file, then load
+ * the file when it's done.
+ */
+
+typedef struct _TiffData TiffData;
+struct _TiffData
+{
+ ModulePreparedNotifyFunc *func;
+ gpointer user_data;
+
+ FILE *file;
+};
+
+gpointer
+image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data)
+{
+ TiffData *context;
+ gint fd;
+ char template[21];
+
+ context = g_new (TiffData, 1);
+ context->func = func;
+ context->user_data = user_data;
+
+ strncpy (template, "/tmp/temp-tiffXXXXXX", strlen ("/tmp/temp-tiffXXXXXX"));
+ fd = mkstemp (template);
+ g_print ("fd=%d\n", fd);
+ context->file = fdopen (fd, "w");
+ if (context->file == NULL)
+ g_print ("it's null\n");
+ else
+ g_print ("it's not null\n");
+ return context;
+}
+
+void
+image_stop_load (gpointer data)
+{
+ TiffData *context = (TiffData*) data;
+ fclose (context->file);
+/* unlink (context->file);*/
+ g_free ((TiffData *) context);
+}
+
+gboolean
+image_load_increment (gpointer data, guchar *buf, guint size)
+{
+ TiffData *context = (TiffData *) data;
+
+ g_assert (context->file != NULL);
+ fwrite (buf, sizeof (guchar), size, context->file);
+ return TRUE;
+}
gboolean closed;
gchar buf[128];
gint buf_offset;
- ModuleType *image_module;
+ GdkPixbufModule *image_module;
gpointer context;
} GdkPixbufLoaderPrivate;